<template>
	<view>
		<!-- #ifdef MP-WEIXIN-->
		<view class="custom_box">
			<image class="bgss" :src="baseUrl + '/static/commonimg/bgImg.jpg'" mode="aspectFill"
				:style="{height: statusBarHeight + titleHeight+5+ 'px'}"></image>
			<view :style="{height: statusBarHeight + 'px'}"></view>
			<view class="custom_addrress" :style="{height: titleHeight + 'px'}">
				<view class="bar_address flex_dq" @click="$u.debounce(gosearchadd, 300)">
					<image class="dws" :src="baseUrl +  '/static/icon/i_dw.png'" mode="aspectFill"></image>
					<text>{{cityName}}</text>
				</view>
				<view class="bar_input flex_dq">
					<image @click="isScanCode" class="sms" :src="baseUrl + '/static/icon/i_sm.png'" mode="aspectFill">
					</image>
					<text class="camouflage" @click="goSearch">请输入</text>
				</view>
			</view>
		</view>
		<view :style="{height: statusBarHeight + titleHeight + 'px'}" style="width: 100%;"></view>
		<!-- #endif -->

		<!-- #ifdef MP-ALIPAY -->
		<view class="custom_box">
			<image class="bgss" :src="baseUrl + '/static/commonimg/bgImg.jpg'" mode="aspectFill"
				:style="{height: statusBarHeight + titleHeight+5 + 'px'}"></image>
			<view class="custom-nav" :style="{height:titleHeight + statusBarHeight + 'px'}">
				<view class="custom_addrress" :style="{height: titleHeight + 'px',paddingTop: btnInfoTop + 15 + 'px' }">
					<view class="bar_address flex_dq" @click="gosearchadd">
						<image class="dws" :src="baseUrl +  '/static/icon/i_dw.png'" mode="aspectFill"></image>
						<text>{{cityName}}</text>
					</view>
					<view class="bar_input flex_dq">
						<image @click="isScanCode" class="sms" :src="baseUrl + '/static/icon/i_sm.png'"
							mode="aspectFill">
						</image>
						<text class="camouflage" @click="goSearch">请输入</text>
					</view>
				</view>
			</view>
		</view>
		<view :style="{height: statusBarHeight + titleHeight + 'px'}" style="width: 100%;"></view>
		<!-- #endif -->





		<!-- #ifdef H5 -->
		<view class="sticky_box">
			<image :src="baseUrl + '/static/commonimg/bgImg.jpg'" mode="aspectFill"></image>
			<view class="sticky_top flex_dq">
				<view class="bar_address flex_dq" @click="gosearchadd">
					<image class="dws" :src="baseUrl + '/static/icon/i_dw.png'" mode="aspectFill"></image>
					<text>{{cityName}}</text>
				</view>
				<view class="bar_input flex_dq">
					<image class="sms" :src="baseUrl + '/static/icon/i_search.png'" mode="aspectFill">
					</image>
					<text class="camouflage" @click="goSearch">请输入</text>
				</view>
			</view>
		</view>
		<!-- #endif -->

		<view class="noticebar_box">
			<image :src="baseUrl + '/static/commonimg/mask2.png'" mode="aspectFill"></image>
			<view class="swipers">
				<u-swiper :list="swiperList" keyName="image" imgMode="scaleToFill" bgColor="transparent" height="148"
					circular @click="clickSwiper"></u-swiper>
			</view>
			<view class="noticeBar">
				<image class="" :src="baseUrl + '/static/image/notice.png'" mode="aspectFill"
					style="width: 86rpx;height: 80rpx;z-index: 99;">
				</image>
				<!-- #ifdef MP-WEIXIN -->
				<u-notice-bar class="noticemain" :text="noticeList" step mode="none" bgColor="#F9F0D6" fontSize="14"
					color="#FFC300" @click="clickNotice"></u-notice-bar>
				<!-- #endif -->
				<!-- #ifdef MP-ALIPAY ||  H5  -->
				<u-notice-bar :text="noticeList" icon='' step mode="none" bgColor="#F9F0D6" fontSize="14"
					color="#FFC300" @click="clickNotice"></u-notice-bar>
				<!-- #endif -->

			</view>
		</view>
		<!-- #ifdef H5 -->
		<view class="stickys" :style="{top: h5TopHeight + 'px'}">
		<!-- #endif -->
			<!-- #ifdef MP-WEIXIN || MP-ALIPAY -->
			<view class="stickys" :style="{top: statusBarHeight + titleHeight+ 'px'}">
			<!-- #endif -->
				<view class="sticky_off">
					<view class="tabs">
						<u-tabs :list="oneLevelList" lineColor="#FFC300" :activeStyle="activeStyle"
							:current="currentIndex" :inactiveStyle="inactiveStyle" :itemStyle="itemStyle"
							@click="clickTabs">

							<view slot="right" style="padding-left: 4px;" @click="toClassify">
								全部
							</view>
						</u-tabs>
					</view>

					<view class="scroll_goods ">
						<view class="goods_box flex_ZC" v-for="(item,index) in twoLevelList" :key="index"
							@click="secondLevel(item)">
							<image :src="item.icon" mode="aspectFill"></image>
							<text class="c3 f26 overflow1">{{item.name}}</text>
						</view>
					</view>
				</view>
			</view>

			<view class="cart flex_c" v-if="cartNumber>0">
				<view class="cart_box flex_dq" @click="goShopCart">
					<image :src="baseUrl + '/static/icon/i_gwc.png'" mode="aspectFill"></image>
					<u-badge max="99" absolute :value="cartNumber" :offset="offset"></u-badge>
				</view>
			</view>
			<view class="zhuanqu">
				<view class="" v-for="(item,index) in recommendList" :key="item.id" @click="secondLevel(item)">
					<image :src="item.icon" mode="aspectFill" class="pinpai"></image>
				</view>
			</view>
			<!-- <qualification/> -->
			<view class="tab-nav">
				<view class="tab-list-item" v-for="(item,index) in toggleList" :key="index"
					@click="clickToggleHandle(item,index)">
					<view :class="{ active: indexs==index}" class="text">{{ item.label }}</view>
					<view class="line" v-if="indexs==index">

					</view>
				</view>
			</view>

			<view class="" v-if="indexs==0">
				<view class="merchant_item" v-for="(item,index) in astoreSellerList" :key="index">
					<view class="flex_dq" style="align-items: flex-start;">
						<image :src="item.logo" mode="aspectFill" class="merchant"></image>
						<view class="flex_Z">
							<view class="f32 c3 shop_name" style="margin-bottom: 20rpx;">{{item.name}}</view>
							<view style="display: flex;align-items: center;">
								<u-rate readonly size="20" v-model="item.evaluate_rate" allowHalf active-color="#FFC300"></u-rate>
								<image class="level_img1" :src="item.attach.seller_level.name_image" mode="widthFix"></image>
								
							</view>
							<!-- <view class=" flex_dq">
								<image class="level_img1" :src="item.attach.seller_level.name_image" mode="widthFix"></image>
								<view class="flex_dq" v-for="(item2,index) in item.attach.seller_level.level_data.image_data" :key="index">
									<image class="level_img2" :src="item2" mode="aspectFill"></image>
								</view>
							</view> -->
						</view>
						
						<view class="f24 c9 " style="height: 100rpx;display: flex;flex-direction: column;justify-content: space-between;" @click="goShopDetails(item)">
							<view style="display: flex;margin-bottom: 20rpx;">
								<view class="">
									进店查看更多
								</view>
								<u-icon name="arrow-right" color="#999999" size="12"></u-icon>
							</view>
							<text class="c6 f24" style="margin-left: 10rpx;" v-if="item.sales_volume!=0">
							 已售 {{ 
							    item.sales_volume_text
							  }}
							</text>
						</view>
					</view>
					<view class="flex_dq">
						<view class="scroll_goods " v-if="item.goods.length>0">
							<view class="flex_ZC shop_item" v-for="iten in item.goods" :key="iten.id"
								@click="goDetails(iten.id)">
								<image :src="iten.thumb" mode="aspectFill"></image>
								<text class="shop_title">{{iten.name}}</text>
								<text class="shop_price">￥{{iten.price}}</text>
							</view>
							<view class="flex_ZC shop_item" v-if="item.is_more==1" @click="goShopDetails(item)">
								<image :src="baseUrl + '/static/image/more.png'" mode=" aspectFill">
								</image>
							</view>
						</view>
						<view class="flex_c" style="width: 100%;" v-else>
							<image class="nodata_img" :src="baseUrl + '/static/image/noData1.png'" mode="aspectFill">
							</image>
						</view>
					</view>
				</view>
				<noDatas :xxxList="astoreSellerList" :status="status"></noDatas>
				<view class="empty">

				</view>

			</view>

			<view class="" v-else>
				<template>
					<view class="">
						<uv-waterfall ref="waterfall" v-model="goodsList" :add-time="10" :left-gap="leftGap"
							:right-gap="rightGap" :column-gap="columnGap" @changeList="changeList">
							<!-- 第一列数据 -->
							<template v-slot:list1>
								<view v-if="goodsList.length>0">
									<view class=" flex_Z" v-for="(item,index) in list1" :key="index"
										@click="goDetails(item.id)">
										<view class="waterfall_box">
											<image :src="item.thumb" mode="widthFix" :style="{width:item.width+'px'}">
											</image>
											<text class="overflow2 goods_name">{{item.name}}</text>
											<text class="gradient1 integral"
												v-if="item.is_not_sale == 0">+{{item.integral_proportion}}%More值</text>
											<text class="sign"
												v-if="item.seller_info&&item.seller_info.company_type !='sole_proprietorship' && item.seller_info&&item.seller_info.company_type !='ordinary'">{{item.seller_info.company_type_text}}</text>
											<text class=" gradient1 integral" v-if="item.is_not_sale == 1">非卖品</text>
											<view class="waterfall_box_price flex_ld">
												<view class=" flex_dq">
													<text class="f24 c4">￥</text>
													<text class="f34 c4 fw7 price">{{item.min_price}}</text>
													<text class="f24 c9 delect"
														v-if="Number(item.max_origin_price) > Number(item.min_price)">￥{{item.max_origin_price}}</text>
												</view>
												<text class="f24 c9"
													v-if="Number(item.max_origin_price) < Number(item.min_price)">已抢{{item.total_sales}}件</text>
											</view>
										</view>
									</view>
								</view>
							</template>
							<!-- 第二列数据 -->
							<template v-slot:list2>
								<view v-if="goodsList.length>0">
									<view class=" flex_Z" v-for="(item,index) in list2" :key="index"
										@click="goDetails(item.id)">
										<view class="waterfall_box">
											<image :src="item.thumb" mode="widthFix" :style="{width:item.width+'px'}">
											</image>
											<text class="overflow2 goods_name">{{item.name}}</text>
											<text class=" gradient1 integral"
												v-if="item.is_not_sale == 0">+{{item.integral_proportion}}%More值</text>
											<text class="sign"
												v-if="item.seller_info&&item.seller_info.company_type !='sole_proprietorship' && item.seller_info&&item.seller_info.company_type !='ordinary'">{{item.seller_info.company_type_text}}</text>
											<text class=" gradient1 integral" v-if="item.is_not_sale == 1">非卖品</text>
											<view class="waterfall_box_price flex_ld">
												<view class=" flex_dq">
													<text class="f24 c4">￥</text>
													<text class="f34 c4 fw7 price">{{item.min_price}}</text>
													<text class="f24 c9 delect"
														v-if="Number(item.max_origin_price) > Number(item.min_price)">￥{{item.max_origin_price}}</text>
												</view>
												<text class="f24 c9"
													v-if="Number(item.max_origin_price) < Number(item.min_price)">已抢{{item.total_sales}}件</text>
											</view>
										</view>
									</view>
								</view>
							</template>
						</uv-waterfall>
					</view>
				</template>
				<noDatas :xxxList="goodsList" :status="status"></noDatas>
			</view>

			<view class="realName_box flex_dq" v-if="closeReal">
				<view class="realName flex_ld" v-if="!userReal">
					<view class=" flex_dq">
						<!-- <u-icon class="btn_gb" name="close" color="#ffffff" size="18" @click="closeReal = false"></u-icon> -->
						<text class="f28 c0">您尚未实名认证</text>
					</view>
					<text class="realname_txt" @click="goRealName">去实名</text>
				</view>
			</view>


			<u-popup :show="phoneShow" mode="center" @close="phoneShow = false" closeable bgColor="transparent">
				<view class="prompt flex_ZC">
					<text class="f36">提示</text>
					<text class="prompt_tit">是否去绑定手机号?</text>
					<view class="prompt_ntm flex_ld_a">
						<text @click="phoneShow = false">取消</text>
						<text @click="goBindPhone">确定</text>
					</view>
				</view>
			</u-popup>
		</view>
</template>

<script>
	import {
		banners,
		notices,
		cloudCategory,
		recommend,
		cloudList,
		sellerList,
		shopActivity
	} from "../../api/cloudMall.js"
	import {
		cartTotalNum
	} from "../../api/shoppingCart.js"
	import {
		geocoder
	} from "../../api/other.js"
	import {
		myuser
	} from "../../api/user.js"
	export default {
		// components: {
		// 	// qualification
		// },
		data() {
			return {
				page: 1,
				size: 10,
				shoppage: 1,
				shopsize: 10,
				status: 'loadmore', //加载前值为loadmore，加载中为loading，没有数据为nomore
				titleTop: 0, //标题顶部距离
				statusBarHeight: 0, //状态栏高度
				titleHeight: 0, // 标题栏高度
				btnInfoTop: 0, //小程序胶囊距离顶部的距离
				baseUrl: this.$imageBaseUrl,
				user: {},
				h5TopHeight: '0',
				lianjie: '',
				// #ifdef H5
				stickyTop2: '40', //吸顶距离
				// #endif

				tabId: 0,
				currentIndex: 0, //一级索引
				cityName: '开启定位', //城市
				offset: [-8, 6], //购物车红点偏移量
				cartNumber: 0, //购物车数量
				levelList: [],
				noticeList: [], //公告/通知
				allShow: false, //分类弹窗
				swiperList: [], //轮播图
				oneLevelList: [], //一级分类
				twoLevelList: [], //二级分类
				goodsList: [], // 瀑布流全部数据
				recommendList: [],
				list1: [], // 瀑布流第一列数据
				list2: [], // 瀑布流第二列数据
				astoreSellerList: [],
				
				toggleList: [{
					label: '商家特卖',
					statusval: "",
					select: true
				}, {
					label: '甄选好货',
					statusval: "1",
					select: false
				}],
				indexs: 0,
				leftGap: 10,
				rightGap: 10,
				columnGap: 10,
				userReal: 0,
				closeReal: false,
				phoneShow: false,
				activeStyle: {
					color: '#333333',
					fontWeight: 'bold',
					fontSize: '14px',
				},
				inactiveStyle: {
					color: '#999999',
					fontSize: '13px',
				},
				itemStyle: {
					height: '34px',
				},
			}
		},
		onReady() {
			// #ifdef MP-ALIPAY 
			let navbarInfo = JSON.parse(uni.getStorageSync("navbarInfo"))
			console.log(navbarInfo, 'navbarInfonavbarInfonavbarInfonavbarInfo');
			this.statusBarHeight = navbarInfo.statusBarHeight;
			this.btnInfoTop = navbarInfo.btnInfoTop;
			this.titleHeight = navbarInfo.titleHeight;
			// #endif

			// #ifdef MP-WEIXIN
			uni.getSystemInfo({
				success: res => {
					this.statusBarHeight = res.statusBarHeight
				}
			})
			const custombar = uni.getMenuButtonBoundingClientRect();
			this.titleHeight = (custombar.top - this.statusBarHeight) * 2 + custombar.height
			console.log(this.titleHeight);
			// #endif
			// #ifdef H5
			uni.createSelectorQuery().select('.sticky_box').boundingClientRect(data => {
				this.h5TopHeight = Number(data.height)  - 2
				console.log('获取顶部高度--',this.h5TopHeight)
			}).exec()
			// #endif

		},

		onLoad() {
			this.initBanner()
			this.initNotices()
			this.initCategory()
			this.getsellerList()
			this.shopActivity()

			console.log(this.$refs.kkkk);
		},
		onShow() {
			// this.allShow = false
			if (this.indexs == 1) {
				this.goodsList = []
				this.list1 = [];
				this.list2 = [];
				this.page = 1
				if (this.tabId == 0) {
					this.initList()
				} else {
					this.twoList()
				}
			}
			this.initCartTotal()
			console.log(uni.getStorageSync('addressInfo'));
			if (uni.getStorageSync('cityName')) {
				this.cityName = uni.getStorageSync('cityName')
			}
			if (uni.getStorageSync('token')) {
				this.closeReal = true
				this.getinfo()
			}
			if (uni.getStorageSync('userReal')) {
				this.userReal = uni.getStorageSync('userReal')
			}
		},

		methods: {

			goShopDetails(item) {
				uni.navigateTo({
					url: '/pagesMy/cloudCat/shopDetails?id=' + item.id
				})
			},
			shopActivity() {
				shopActivity().then(res => {
					console.log(res, 'shopActivity');
					this.recommendList = res.data
				})
			},
			getsellerList() {
				let data = {
					page: this.page,
					page_size: this.size,
					mask: 1
				};
				sellerList(data).then(res => {
					console.log(res, 'getsellerList');
					let list = res.data.data;
					this.astoreSellerList = this.page == 1 ? list : this.astoreSellerList.concat(list);
					console.log(this.astoreSellerList);
					if (list.length < this.size) this.status = 'nomore';
					else this.status = 'loading';
				})
			},
			goBindPhone() {
				this.phoneShow = false
				uni.navigateTo({
					url: '/pageUser/myuser/bindphone'
				})
			},
			clickToggleHandle(ele, index) {
				// this.statusval=ele.statusval
				var that = this
				this.page = 1
				this.indexs = index
				this.toggleList.forEach(item => item.select = false)
				console.log(this.indexs);
				setTimeout(() => {
					if (index == 1) {
						that.page = 1
						that.goodsList = []
						that.$refs.waterfall.clear();
						that.list1 = [];
						that.list2 = [];
						console.log(that.tabId);
						if (that.tabId == 0) {
							that.initList()
						} else {
							that.twoList()
						}
					}
				}, 100)

				// this.currLabel = ele.label
				// if (this.indexs == 0) {
				// 	this.page = 1

				// 	this.initList()
				// }
				// if (this.indexs == 1) {
				// 	this.latitude=uni.getStorageSync("latitude")
				// 	this.longitude=uni.getStorageSync("longitude")
				// 	this.page2 = 1
				// 	this.getlist()
				// }
				ele.select = true

			},

			toClassify() {
				uni.navigateTo({
					url: '/pagesMy/cloudCat/shopClassify'
				})
			},

			getinfo() {
				myuser().then(res => {
					if (res.code == 1) {
						console.log(res)
						this.user = res.data
						this.userReal = res.data.is_real
						uni.setStorageSync('hx_im_token', res.data.hx_im_token)
						uni.setStorageSync('userReal', res.data.is_real)
						getApp().globalData.userInfo = res.data
						if (res.data.mobile == '') {
							this.phoneShow = true
						}
						if (uni.getStorageSync("hx_im_token") && !uni.getStorageSync("is_hxlogin")) {
							this.login()
						}
					}
				})
			},
			login() {
				console.log('环信登录');
				let that = this
				var options = {
					user: that.user.id.toString(),
					accessToken: that.user.hx_im_token,
					appKey: uni.WebIM.config.appkey
				};
				console.log(options);
				uni.WebIM.conn.open(options).then(res => {
						console.log(res, "查看")
						uni.setStorageSync("is_hxlogin", 1)
					})
					.catch((reason) => {
						console.log("login fail", reason);
					});
				// console.log("登录成功")

				// console.log("登录成功")

			},
			gosearchadd() {
				uni.navigateTo({
					url: "/pagesMy/groundCat/searchadd"
				})
			},
			goSearch() {
				uni.navigateTo({
					url: "/pagesMy/cloudCat/secondLevelSearch?type=0"
				})
			},
			// 这点非常重要：e.name在这里返回是list1或list2，要手动将数据追加到相应列
			changeList(e) {
				// console.log(e);
				this[e.name].push(e.value);
			},

			// 轮播图
			initBanner() {
				banners().then(res => {
					console.log('轮播', res)
					if (res.code == 1) {
						this.swiperList = res.data
					}
				})
			},
			// 公告
			initNotices() {
				notices({
					page: 1,
					type: 1
				}).then(res => {
					console.log('公告', res)
					if (res.code == 1) {
						let oldNotice = res.data.data;
						console.log(oldNotice);
						let newLsit = [];
						oldNotice.forEach((item, index) => {
							newLsit.push(item.title)
						})
						console.log(newLsit);
						this.noticeList = newLsit
					}
				})
			},
			// 分类
			initCategory() {
				cloudCategory().then(res => {
					console.log('分类', res)
					if (res.code == 1) {
						this.oneLevelList = res.data
						this.twoLevelList = res.data[0].children
					}
				})
			},
			// 购物车数量
			initCartTotal() {
				cartTotalNum().then(res => {
					console.log('购物车', res)
					if (res.code == 1) {
						this.cartNumber = res.data.total_num
					}
				})
			},
			// 初始化列表
			initList() {
				let data = {
					page: this.page,
					page_size: this.size,
					mask: 1
				};
				recommend(data).then(res => {
					console.log('商品列表', res)
					let list = res.data.data;
					this.goodsList = this.page == 1 ? list : this.goodsList.concat(list);
					console.log(this.goodsList);
					if (list.length < this.size) this.status = 'nomore';
					else this.status = 'loading';
				})
			},
			// 二级分类
			clickTabs(e) {
				console.log(e);
				this.tabId = e.id
				this.currentIndex = e.index
				this.twoLevelList = e.children
				this.page = 1
				this.goodsList = []
				if (this.indexs == 0) {
					return
				}
				this.$refs.waterfall.clear();
				this.list1 = [];
				this.list2 = [];

				if (this.tabId == 0) {
					this.initList()
				} else {
					this.twoList()
				}
			},
			twoList() {
				let data = {
					page: this.page,
					page_size: this.size,
					search_name: '',
					category_id: this.tabId,
					sort_field: '',
					sort_by: '',
					mask: 1
				};
				cloudList(data).then(res => {
					console.log('商品列表', res)
					let list = res.data.data;
					this.goodsList = this.page == 1 ? list : this.goodsList.concat(list);
					// console.log(this.goodsList);
					if (list.length < this.size) this.status = 'nomore';
					else this.status = 'loading';
				})
			},
			clickNotice() {
				uni.navigateTo({
					url: "/pageDao/Dao/noticelist?type=1"
				})

			},
			// 定位
			obtainAddress() {
				let that = this;
				uni.getLocation({
					success: function(res) {
						console.log(res);
						console.log('当前位置的经度：' + res.longitude);
						console.log('当前位置的纬度：' + res.latitude);
						let data = {
							lat: res.latitude,
							lng: res.longitude,
						};
						geocoder(data).then(res => {
							console.log('逆解析', res)
							if (res.code == 1) {
								that.cityName = res.data.city
								console.log(that.cityName);
								uni.setStorageSync('addressInfo', res.data)
							}
						})
					},
					fail: function(res) {
						console.log(res, "杀杀杀杀杀杀杀杀杀")
					}
				})
			},
			goDetails(id) {
				console.log(id);
				uni.navigateTo({
					url: '/pagesMy/cloudCat/goodsDetails?id=' + id
				})
			},
			// 扫码
			isScanCode() {
				// 只允许通过相机扫码
				uni.scanCode({
					// onlyFromCamera: true, // 如果需要仅从相机扫码，可以取消注释
					success: function(res) {
						console.log(res, "扫码结果"); // 打印扫码结果，方便调试

						// 获取扫码结果中的 URL
						let url = res.result; // 注意：res.refult 应该是 res.result
						console.log("扫码获取的 URL:", url);

						// 检查 URL 是否存在
						if (url) {
							// 截取 # 之后的内容
							const hashpart = url.split('#')[1] || '';
							const hashpart2 = url.split('=')[1] || '';
							console.log("截取 # 之后的内容:", hashpart);

							// 如果截取到有效内容，跳转到对应页面
							if (hashpart) {
								const codeIndex = hashpart.indexOf('pay_code=');
								const codeIndex2 = hashpart.indexOf('code=');
								if (codeIndex !== -1) {
									// 提取 code 参数的值
									const codeValue = hashpart.substring(codeIndex + 9);
									uni.setStorageSync("pay_code", codeValue);
									console.log("提取到的 code 值:", codeValue);
								} else {
									// 提取 code 参数的值
									const codeValue = hashpart.substring(codeIndex2 + 5);
									uni.setStorageSync("code", codeValue);
									console.log("提取到的 code 值:", codeValue);
								}
								uni.setStorageSync("quick_pay", hashpart)
								uni.reLaunch({
									url: hashpart
								});
								// 存储 code 到本地

							} else {
								console.error("URL 中没有 # 后的内容");
								uni.showToast({
									title: 'URL 格式不正确',
									icon: 'none'
								});
							}

						} else {
							console.error("扫码结果中没有 URL");
							uni.showToast({
								title: '扫码失败，请重试',
								icon: 'none'
							});
						}

						// 打印条码类型和内容
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
					},
					fail: function(err) {
						console.error("扫码失败:", err);
						uni.showToast({
							title: '扫码失败，请重试',
							icon: 'none'
						});
					}
				});
			},
			// 去搜索
			// goSearch() {
			// 	uni.navigateTo({
			// 		url: '/pagesMy/cloudCat/cloudSearch'
			// 	})
			// },
			// 轮播图跳转
			clickSwiper(index) {
				console.log('轮播下标', index);
				let lunboInfo = this.swiperList[index];
				console.log(lunboInfo);
				if (lunboInfo.jump) {
					if (lunboInfo.type == 1) {
						uni.navigateTo({
							url: '/pagesMy/cloudCat/goodsDetails?id=' + lunboInfo.goods_id
						})
					} else if (lunboInfo.type == 2) {
						console.log('热门活动111');
						uni.navigateTo({
							url: '/pagesMy/cloudCat/eventCenter?id=' + lunboInfo.hot_recommend_id
						})
					}

				}
			},
			// 去二级分类
			secondLevel(item) {
				if (item.type == 1 && item.pid > 0) {
					let info = {
						id: item.id,
						name: '',
					}
					uni.setStorageSync('nextFloor', info)
					uni.navigateTo({
						url: '/pagesMy/cloudCat/secondLevelSearch?type=0'
					})
				} else if (item.type == 1 && item.pid == 0) {
					console.log('改一级分类');
					this.oneLevelList.forEach((kk, index) => {
						if (item.id == kk.id) {
							this.tabId = kk.id
							this.currentIndex = index
							this.page = 1
							this.goodsList = []
							if (this.indexs == 0) {
								return
							}
							this.$refs.waterfall.clear();
							this.list1 = [];
							this.list2 = [];
							this.twoList()
						}
					})
				} else if (item.type == 2) {
					console.log('热门活动');
					if (item.is_prepare == 1) {
						uni.$u.toast(item.prepare_tip)
					} else {
						uni.navigateTo({
							url: '/pagesMy/cloudCat/eventCenter?id=' + item.id
						})
					}

				}
			},
			// 去购物车
			goShopCart() {
				uni.navigateTo({
					url: '/pagesMy/cloudCat/shoppingCart'
				})
			},
			// 去实名
			goRealName() {
				uni.navigateTo({
					url: "/pageUser/myuser/realname"
				})
			},

			// 瀑布流回调
			waterfallBack(e) {
				// console.log(e);
				console.log('id是---', e.id);
				uni.navigateTo({
					url: '/pagesMy/cloudCat/goodsDetails?id=' + e.id
				})
			},
		},
		onHide() {
			if (this.indexs != 0) {
				this.$refs.waterfall.clear();
			}
		},
		//触底加载
		onReachBottom() {
			console.log('触底加载');
			if (this.status != 'nomore') {
				this.page = this.page + 1
				if (this.indexs == 0) {
					this.getsellerList()
				} else {
					if (this.tabId == 0) {
						this.initList()
					} else {
						this.twoList()
					}
				}


			}
		}
	}
</script>


<style scoped lang="scss">

	.custom_box {
		width: 750rpx;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 998;
		padding-bottom: 10rpx;
		opacity: 1;
	}

	.bgss {
		position: absolute;
		width: 750rpx;
	}


	.custom_addrress {
		display: flex;
		align-items: center;
		font-size: 36rpx;
		z-index: 999;
		color: #FFFFFF;
		/* #ifdef MP-ALIPAY */
		margin-left: 30rpx;
		line-height: 88rpx;
		/* #endif */
	}

	.sticky_box {
		position: sticky;
		top: -2rpx;
		width: 750rpx;
		// height: 170rpx;
		z-index: 999;
	}

	.sticky_box>image {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		display: block;
	}

	.noticebar_box {
		position: relative;
		width: 750rpx;
		border-radius: 10rpx;
		/* #ifdef H5 */
		// padding-top: 30rpx;
		/* #endif */
		// 
	}

	.noticebar_box>image {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 224rpx;
	}

	.tab-nav {
		width: 690rpx;
		height: 100rpx;
		background-color: #fff;
		display: flex;
		align-items: center;
		justify-content: space-around;
		margin: 0 auto;
		margin-top: 18rpx;
		border-radius: 14rpx;
		margin-bottom: 20rpx;
		position: relative;
		z-index: 2;
	}

	.tab-list-item {
		position: relative;
	}

	.text {
		display: flex;
		justify-content: center;
		align-items: center;
		padding: 10rpx;
		opacity: 1;
		font-weight: 500;
		text-align: center;
		font-size: 32rpx;
		color: #A6A5AF;
		z-index: 99;
		position: relative;
	}

	.active {
		font-weight: 700;
		color: #333333;
		z-index: 98;
		position: relative;
	}

	.line {
		width: 66rpx;
		height: 10rpx;
		background: linear-gradient(90deg, #FA2222 2%, #FFC400 98%);
		border-radius: 118rpx 118rpx 118rpx 118rpx;
		position: absolute;
		top: 85%;
		left: 50%;
		transform: translate(-50%);
		z-index: 60;
	}

	.sticky_top {
		position: relative;
		width: 750rpx;
		// height: 88rpx;
		z-index: 9;
		/* #ifdef H5 */
		padding-top: 20rpx;
		/* #endif */

		/* #ifdef MP-WEIXIN||MP-ALIPAY */
		padding-top: 70rpx;
		/* #endif */
	}

	.zhuanqu {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		justify-content: space-between;
		width: 690rpx;
		margin: 0 auto;

	}
	.level_img1 {
		width: 116rpx;
		height: 38rpx;
		margin-right: 14rpx;
	}
	
	.level_img2 {
		width: 30rpx;
		height: 30rpx;
	}

	.pinpai {
		width: 336rpx;
		height: 216rpx;
		margin-top: 38rpx;
	}

	.bar_address {
		display: flex;
		align-items: center;
		// min-width: 160rpx;
		height: 106rpx;
		margin-left: 35rpx;
		position: relative;
	}

	.bar_address>text {

		/* #ifdef MP-WEIXIN  || H5 */
		width: 140rpx;
		/* #endif */
		/* #ifdef MP-ALIPAY */
		max-width: 120rpx;
		margin-right: 5rpx;
		/* #endif */
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		font-size: 30rpx;
		color: #333333;
		margin: 0 10rpx;
	}

	.dws {
		width: 22rpx;
		height: 28rpx;
	}

	.bar_input {

		position: relative;
		height: 64rpx;
		background: #ffffff;
		border-radius: 40rpx;
		// margin-left: 24rpx;
	}

	.bar_input::before {
		content: '';
		position: absolute;
		top: 18rpx;
		left: 70rpx;
		transform: translateX(-50%);
		height: 30rpx;
		width: 2rpx;
		background: #E5E5E5;
	}

	.sms {
		width: 32rpx;
		height: 30rpx;
		margin-left: 26rpx;
	}

	.camouflage {
		/* #ifdef MP-ALIPAY */
		width: 170rpx;
		/* #endif */
		/* #ifdef MP-WEIXIN */
		width: 240rpx;
		/* #endif */
		/* #ifdef H5 */
		width: 400rpx;
		/* #endif */
		margin-left: 36rpx;
		font-size: 28rpx;
		color: #999999;
	}

	.merchant_item {
		width: 690rpx;
		height: 462rpx;
		margin: 0 auto;
		padding: 26rpx 0 26rpx 18rpx;
		background: #fff;
		border-radius: 14rpx;
		overflow: hidden;
		margin-top: 20rpx;
	}

	.merchant {
		width: 100rpx;
		height: 100rpx;
		border-radius: 12rpx;
		margin-right: 28rpx;
	}

	.shop_name {
		width: 270rpx;
		margin-right: 86rpx;
		text-overflow: ellipsis;
		overflow: hidden;
		white-space: nowrap;
	}

	.shop_item {
		margin-right: 16rpx;
		margin-top: 24rpx;
		align-items: flex-start;

		image {
			width: 180rpx;
			height: 180rpx;
			border-radius: 12rpx;
		}

		.shop_title {
			width: 180rpx;
			font-weight: 400;
			font-size: 28rpx;
			color: #3D3D3D;
			line-height: 28rpx;
			text-overflow: ellipsis;
			overflow: hidden;
			white-space: nowrap;
			margin-top: 34rpx;
		}

		.shop_price {
			font-weight: bold;
			font-size: 30rpx;
			color: #E78C4C;
			line-height: 32rpx;
			margin-top: 12rpx;
		}

	}

	.noticeBar {
		position: relative;
		width: 690rpx;
		height: 76rpx;
		margin: 0 auto 24rpx;
		z-index: 2;
		border-radius: 10rpx;
		background: linear-gradient(90deg, rgba(255, 255, 255, 0.2) 10%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 99%);
		display: flex;
		align-items: center;

	}

	/deep/ .u-notice-bar {
		margin-left: -30rpx;
		/* #ifdef MP-WEIXIN */
		margin-left: -62rpx;
		/* #endif */
		padding-left: 40rpx;
		z-index: 1;
	}

	.swipers {
		position: relative;
		width: 690rpx;
		/* #ifdef MP-WEIXIN||MP-ALIPAY */
		margin: 10rpx auto 24rpx;
		/* #endif */

		/* #ifdef H5 */
		margin: 0rpx auto 24rpx;
		/* #endif */
		z-index: 2;
	}

	.tttt {
		position: sticky;
		top: 0;
		left: 0;
		z-index: 9;
	}

	.stickys {
		position: sticky;
		top: 0;
		left: 0;
		z-index: 9;
	}

	.sticky_off {
		padding: 10rpx 0;
		background: #F5F7F5;
		padding-bottom: 10rpx;
		/* background: pink; */
	}

	.tabs {
		position: relative;
		width: 690rpx;
		margin-left: 30rpx;
	}

	.alls {
		position: absolute;
		top: 14rpx;
		right: -4rpx;
		font-size: 28rpx;
		font-weight: bold;
		color: #333333;
		background: #F5F7F5;
		width: 80rpx;
		text-align: right;
	}

	.scroll_goods {
		display: flex;
		width: 690rpx;
		margin: 10rpx auto;
		overflow: auto;
	}

	.scroll_goods2 {
		display: flex;
		flex-wrap: wrap;
		width: 690rpx;
		margin: 24rpx auto;
		overflow: auto;
	}

	.goods_box {
		width: 120rpx;
		margin-right: 20rpx;
	}

	.goods_box2 {
		width: 96rpx;
		margin-right: 40rpx;
		margin-bottom: 30rpx;
	}

	.goods_box>image {
		width: 112rpx;
		height: 108rpx;
		margin-bottom: 12rpx;
	}

	.goods_box2>image {
		width: 96rpx;
		height: 96rpx;
		margin-bottom: 12rpx;
	}

	.cart {
		position: fixed;
		bottom: 200rpx;
		right: 30rpx;
		width: 96rpx;
		height: 96rpx;
		background: #FFFFFF;
		border-radius: 50%;
		z-index: 3;
		box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
	}

	.cart_box {
		position: relative;
		width: 100%;
		height: 1005;
		/* background: pink; */
	}

	.cart_box>image {
		width: 36rpx;
		height: 36rpx;
		margin-left: 28rpx;
	}


	.cnt {
		padding: 10px;
	}

	.title {
		font-size: 16px;
	}

	.text {
		font-size: 14px;
		margin-top: 5px;
	}

	.classification {
		width: 750rpx;
		/* height: 800rpx; */
		background: #ffffff;
		padding: 30rpx 30rpx 10rpx;
		border-radius: 0 0 40rpx 40rpx;
	}

	.putItAway {
		width: 100%;
		padding: 20rpx 0;
		border-top: 1rpx solid #F2F2F2;
	}

	.waterfall_box {
		width: 350rpx;
		margin-bottom: 20rpx;
		padding-bottom: 10rpx;
		background: #ffffff;
		border-radius: 20rpx;
	}

	.waterfall_box>image {
		border-radius: 20rpx 20rpx 0 0;
	}

	.goods_name {
		font-size: 28rpx;
		color: #333333;
		padding: 0 10rpx;
	}

	.integral {
		font-size: 24rpx;
		color: #ffffff;
		padding: 4rpx 14rpx;
		border-radius: 10rpx;
		margin-left: 10rpx;
	}

	.waterfall_box_price {
		margin-top: 20rpx;
		padding: 0 10rpx;
	}

	.price {
		margin-right: 6rpx;
	}

	.realName_box {
		width: 680rpx;
	}

	.nodata_img {
		width: 290rpx;
		height: 240rpx;
	}

	.realName {
		position: fixed;
		/* #ifdef MP-WEIXIN||MP-ALIPAY */
		bottom: 0;
		/* #endif */

		/* #ifdef H5 */
		bottom: 100rpx;
		/* #endif */
		left: 50%;
		transform: translateX(-50%);
		width: 680rpx;
		height: 88rpx;
		background: rgba(0, 0, 0, 0.7);
		border-radius: 28rpx 28rpx 28rpx 28rpx;
		z-index: 999;
		padding: 0 26rpx;
	}

	.btn_gb {
		margin-right: 14rpx;
	}

	.realname_txt {
		width: 142rpx;
		height: 52rpx;
		line-height: 52rpx;
		text-align: center;
		background: #FFC300;
		font-size: 28rpx;
		color: #332C2B;
		border-radius: 154rpx 154rpx 154rpx 154rpx;
	}



	.sign {
		/* width: 76rpx;
		height: 28rpx; */
		background: #FFC300;
		border-radius: 8rpx;
		font-size: 22rpx;
		color: #FFFFFF;
		text-align: center;
		line-height: 28rpx;
		margin-left: 16rpx;
		padding: 2rpx 4rpx;
	}

	.prompt {
		width: 600rpx;
		background: #ffffff;
		margin: 0 auto;
		border-radius: 20rpx;
		padding-top: 10rpx;
		padding-bottom: 40rpx;
	}

	.prompt>text {
		margin-top: 40rpx;
	}

	.prompt_tit {
		margin: 0 30rpx;
		font-size: 28rpx;
		color: #666666;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}

	.prompt_ntm {
		width: 100%;
		font-size: 30rpx;
		margin-top: 50rpx;
	}

	.prompt_ntm>text:nth-child(1) {
		width: 200rpx;
		height: 72rpx;
		line-height: 72rpx;
		text-align: center;
		background: #F2F2F2;
		border: 1rpx solid #F2F2F2;
		border-radius: 40rpx;
		color: #333333;
	}

	.prompt_ntm>text:nth-child(2) {
		width: 200rpx;
		height: 72rpx;
		line-height: 72rpx;
		text-align: center;
		background: linear-gradient(90deg, #FA2222 2%, #FFC400 98%);
		border-radius: 40rpx;
		color: #ffffff;
	}

	.noticeBarimgssss {}

	.noticemain {
		position: absolute;
		left: 80rpx;
	}

	/deep/.u-notice-bar {
		border-radius: 16rpx;
	}

	/deep/.u-tabs {
		background: #f7f7f7;
	}

	/deep/.u-notice__swiper__item__text {
		color: #999 !important;
	}
</style>